<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'dayManage.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	 <link rel="stylesheet" type="text/css" href="jsTools/bootstrap-3.3.7-dist/css/bootstrap.min.css">
	<script type="text/javascript" src="jsTools/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
	
	<link rel="stylesheet" type="text/css" href="jsTools/jquery-easyui-1.5.1/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="jsTools/jquery-easyui-1.5.1/themes/icon.css">
	<script type="text/javascript" src="jsTools/jquery-easyui-1.5.1/jquery.min.js"></script>
	<script type="text/javascript" src="jsTools/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="jsTools/jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js" charset="utf-8"></script>
  </head>
  
  <body>
    <div class="container">
   		<div class="row clearfix">
	
   				<div class="col-sm-2" >
   				
   				<ul class="list-unstyled list-inline">
   					<li><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" id="add">增加日程</a></li>
   					<li><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="look">查看日程</a></li>
   					<li><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" id="updata">修删日程</a></li>
   				</ul>
				
   				</div>
   		<div class="col-sm-10">
   				<div id="divlook">
   				<div class="col-sm-12 "><input type="text" class="easyui-datebox" data-options="required:true" id="seachar"><button id="bSeachar" class="btn btn-link" ><span class=" glyphicon glyphicon-search"></span>查找</button></div>
   				<table class="table table-bordered table-hover table-condensed">
				<thead>
					<tr><th>日程时间</th><th>日程内容</th></tr>
				</thead>	
				<tbody>	
				</tbody>
				</table>
   				</div>
   				<div id="divadd" >
   						<form id="addform" action="dateManage!insert.action"  method="post">
   				<table class="table table-bordered table-hover table-condensed" >
				<thead>
					
				<tbody>
					<tr>
						<td>
							日程时间
						</td>
						<td >
							<input name="date" type="text"  class="easyui-datebox" data-options="required:true">
						</td>						
					</tr>
					<tr class="success">
						<td>
							日程内容
						</td>
						<td>
							<textarea name="thing" ></textarea>
						</td>
						
					</tr>
				</tbody>
			</table>  
				<div  class="col-sm-6 col-sm-offset-3"><button   type="submit" class="btn btn-primary btn-default pull-left" ><span class=" glyphicon glyphicon-plus"></span>确定</button>
				<button  type="reset" class="btn  btn-default pull-right">清除</button></div>  						
				</form>
				</div>
   		<div id="divupdata" class="col-sm-4 col-sm-offset-4">
   		<div class="col-sm-12 "><input type="text" class="easyui-datebox" data-options="required:true" id="useachar"><button id="ubSeachar" class="btn btn-link" ><span class=" glyphicon glyphicon-search"></span>查找</button></div>		
			<div id="divupdata_div" class="easyui-dialog col-sm-12" title="日程修改、删除" 
			data-options="
				 closed :true,
				iconCls: 'icon-save',
				toolbar: [{
					text:'修改',
					iconCls:'icon-edit',
					handler:function(){var date= $('#divupdata_div input[name=date]').val(); var d=$('#divupdata_div textarea').serialize();alert(d);
				$.post('dateManage!updata.action','date='+date+'&'+d,function(data){if(data=='true') {alert('修改成功');$('#divupdata_div').dialog('close');} else alert('修改失败') })		
					}
				},'-',{
					text:'删除',
					iconCls:'icon-remove',
					handler:function(){var date=$('#divupdata_div input[name=date]').val(); 
						$.post('dateManage!delect.action',{'date':date},function(data){if(data=='true') {alert('删除成功');$('#divupdata_div').dialog('close');} else alert('删除失败') })
					}
				}],
			">
			<table class="table table-bordered table-hover table-condensed" >
				<thead>
					
				<tbody>
					<tr>
						<td>
							日程时间
						</td>
						<td >
							<input name="date"  disabled="disabled" type="text">
						</td>						
					</tr>
					<tr class="success">
						<td>
							日程内容
						</td>
						<td>
							<textarea name="thing" type="text"></textarea>
						</td>
						
					</tr>
					
				</tbody>
			</table>  
	</div>	
   						</div>
   				</div>
   		</div>  	
   	</div>
  </body>
  <script type="text/javascript">
  		
  $(function(){$("#divadd").css("display","none");$("#divupdata").css("display","none");
  		$.get("dateManage!select.action",function(data){ var s=JSON.parse(data);
  						for(var i=0;i<s.length;i++)
  						{
  							$("#divlook table tbody").append("<tr><td>"+s[i].date+"</td><td>"+s[i].thing+"</td></tr>");
  						}
  		});
  
  });
  		
  	$("#look").click(function() {$("#divlook table tbody").empty();$("#divlook").css("display","block");$("#divadd").css("display","none");$("#divupdata").css("display","none");
  	$.get("dateManage!select.action",function(data){ var s=JSON.parse(data);
  						for(var i=0;i<s.length;i++)
  						{
  							$("#divlook table tbody").append("<tr><td>"+s[i].date+"</td><td>"+s[i].thing+"</td></tr>");
  						}
  		});
  	});
  	$("#bSeachar").click(function() {
  	if($("#seachar").val()!=''){
		$.post("dateManage!oneSelect.action",{"date":$("#seachar").val()},function(data) {
		var s=JSON.parse(data);$("#divlook table tbody").empty(); if(s.date!='') $("#divlook table tbody").append("<tr><td>"+s.date+"</td><td>"+s.thing+"</td></tr>"); else alert("日程不存在");
				});}
		});
$("#add").click(function() {$("#divlook").css("display","none");$("#divadd").css("display","block");$("#divupdata").css("display","none");});
$("#updata").click(function() {$("#divlook").css("display","none");$("#divadd").css("display","none");$("#divupdata").css("display","block");});
 
	$("#ubSeachar").click(function() {
  	if($("#useachar").val()!=''){
		$.post("dateManage!oneSelect.action",{"date":$("#useachar").val()},function(data) {
		var s=JSON.parse(data); if(s.date!=''){ $('#divupdata_div').dialog('open'); $.each(s, function(k, v){$("#divupdata_div input[name="+k+"]").val(v);$("#divupdata_div textarea[name="+k+"]").html(v);});}  else alert("日程不存在");
				});}
		});  	
  		
  </script>
</html>
